package org.chen.common.scene.dto.api;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
import javax.validation.Valid;

@Data
@Schema(description = "携程API请求参数")
public class CtripApiRequest {

    @Schema(description = "请求头信息",
            requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "请求头信息不能为空")
    @Valid
    private Head head;

    @Schema(description = "场景类型",
            example = "online",
            allowableValues = {"online", "offline", "test"},
            defaultValue = "online")
    @NotBlank(message = "场景类型不能为空")
    private String scene = "online";

    private String keyword;

    @Schema(description = "地区/区域ID",
            example = "123456",
            requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Positive(message = "地区ID必须为正数")
    private Long districtId;

    @Schema(description = "页码索引(从0开始)",
            example = "0",
            minimum = "0",
            requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Min(value = 0, message = "页码索引不能小于0")
    private Integer index;

    @Schema(description = "排序类型",
            example = "1",
            allowableValues = {"1", "2", "3", "4", "5"},
            requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Min(value = 1, message = "排序类型必须大于0")
    @Max(value = 10, message = "排序类型不能超过10")
    private Integer sortType;

    @Schema(description = "返回数据条数",
            example = "20",
            minimum = "1",
            maximum = "100",
            requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Min(value = 1, message = "返回数据条数至少为1")
    @Max(value = 100, message = "返回数据条数不能超过100")
    private Integer count;

    @Schema(description = "过滤条件",
            requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Valid
    private Filter filter;

    @Schema(description = "坐标信息",
            requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Valid
    private Coordinate coordinate;

    @Schema(description = "返回模块类型",
            example = "all",
            allowableValues = {"all", "basic", "detail", "price"},
            defaultValue = "all")
    @NotBlank(message = "返回模块类型不能为空")
    private String returnModuleType = "all";

    @Data
    public static class Head {
        private String cid = "09031085319942862668";
        private String ctok = "";
        private String cver = "1.0";
        private String lang = "01";
        private String sid = "8888";
        private String syscode = "999";
        private String auth = "";
        private String xsid = "";
        private List<Object> extension = List.of();
    }

    @Data
    public static class Filter {
        private List<String> filterItems;
    }

    @Data
    public static class Coordinate {
        private BigDecimal latitude;
        private BigDecimal longitude;
        private String coordinateType = "WGS84";
    }
}